package cn.yusei.teamTribe.dao.team;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.yusei.teamTribe.dao.team.po.TeamPO;

@Mapper
public interface TeamInfoDAO {

	final String TEAM_TABLE = " e_team ";
	final String SELECT_FIELDS = " id, school_id, name, portrait, score, create_time, comment, wallpaper ";
	
	@Select({"select", SELECT_FIELDS, "from", TEAM_TABLE, "where id = #{id}"})
	TeamPO selectById(@Param("id") int id);
	
	@Select({"select school_id from", TEAM_TABLE, "where id = #{id}"})
	Integer selectSchoolId(@Param("id") int id);	
	
	@Update({"update ",TEAM_TABLE,"set name = #{name},portrait = #{portrait},"
			+ "comment = #{comment},wallpaper = #{wallpaper} where id = #{id} "})
	void updateById(TeamPO teamPO);
	
	@Select({"select id from ",TEAM_TABLE,"where name = #{name}"})
	Integer selectIdByName(@Param("name")String name);
}
